package cn.wp.ewallet.wmps.dao.impl;

import cn.wp.common.core.dao.JdbcSupportTemplate;
import cn.wp.common.core.dao.SqlString;
import cn.wp.ewallet.wmps.dao.FixProdOrderRelDao;
import cn.wp.ewallet.wmps.model.entity.FixProdOrderRelDo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * Created by yangjin on 2020/1/11
 */
@Repository
public class FixProdOrderRelDaoImpl implements FixProdOrderRelDao {

    @Autowired
    private JdbcSupportTemplate jdbcSupportTemplate;

    @Override
    public void saveFixProdOrderRel(FixProdOrderRelDo fixProdOrderRelDo) {
        jdbcSupportTemplate.insert(fixProdOrderRelDo);
    }

    @Override
    public void updateFixProdOrderRel(FixProdOrderRelDo fixProdOrderRelDo) {
        jdbcSupportTemplate.update(fixProdOrderRelDo);
    }

    @Override
    public FixProdOrderRelDo selectFixProdOrderRelByProdOrderId(String prodOrderId) {
        SqlString sqlString = SqlString.newInstance();
        sqlString.add("select *");
        sqlString.add("from fix_prod_order_rel");
        sqlString.add("where PROD_ORDER_ID = ?");
        return jdbcSupportTemplate.selectObject(sqlString.build(),new Object[]{prodOrderId},FixProdOrderRelDo.class);
    }
}
